package org.example.Swing.xiangmu.login;
import org.example.Swing.handler.AddHandler;

import javax.swing.*;
import java.awt.*;

public class AddView extends JDialog {
    JPanel jPanel = new JPanel(new FlowLayout(FlowLayout.CENTER,10,20));
    JLabel nameLabel = new JLabel("姓名:",JLabel.RIGHT);
    JTextField nameTxt = new JTextField();
    JLabel noLabel = new JLabel("学号:",JLabel.RIGHT);
    JTextField noTxt = new JTextField();
    JLabel kcLabel = new JLabel("课程:",JLabel.RIGHT);
    JTextField kcTxt = new JTextField();
    JLabel psLabel = new JLabel("平时成绩:",JLabel.RIGHT);
    JTextField pstext = new JTextField();
    JLabel kscjLabel = new JLabel("考试成绩:",JLabel.RIGHT);
    JTextField kstext = new JTextField();
    JButton addBtn = new JButton("添加");
    JButton addKcBtn = new JButton("添加课程");
    AddHandler addHandler;
    public AddView(MainView mainView){
        super(mainView,"添加学生",true);

        addHandler = new AddHandler(this,mainView);
        nameLabel.setPreferredSize(new Dimension(80,30));
        jPanel.add(nameLabel);
        nameTxt.setPreferredSize(new Dimension(200,30));
        jPanel.add(nameTxt);

        noLabel.setPreferredSize(new Dimension(80,30));
        jPanel.add(noLabel);
        noTxt.setPreferredSize(new Dimension(200,30));
        jPanel.add(noTxt);

        kcLabel.setPreferredSize(new Dimension(80,30));
        jPanel.add(kcLabel);
        kcTxt.setPreferredSize(new Dimension(200,30));
        jPanel.add(kcTxt);

        psLabel.setPreferredSize(new Dimension(80,30));
        jPanel.add(psLabel);
        pstext.setPreferredSize(new Dimension(200,30));
        jPanel.add(pstext);

        kscjLabel.setPreferredSize(new Dimension(80,30));
        jPanel.add(kscjLabel);
        kstext.setPreferredSize(new Dimension(200,30));
        jPanel.add(kstext);

        addBtn.addActionListener(addHandler);
        addKcBtn.addActionListener(addHandler);
        jPanel.add(addBtn);
        jPanel.add(addKcBtn);

        Container contentPane = getContentPane();
        contentPane.add(jPanel);
        getRootPane().setDefaultButton(addBtn);
        setSize(350,500);
        setLocationRelativeTo(null);
        // DISPOSE_ON_CLOSE:只销毁当前的窗体
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        setResizable(false);
        setVisible(true);
    }
    public JTextField getNameTxt() {return nameTxt;}
    public JTextField getKcTxt() {return kcTxt;}
    public JTextField getPstext() {return pstext;}
    public JTextField getKstext() {return kstext;}
    public JTextField getNoText() {return noTxt;}

}
